using System;
using System.Collections.Generic;
using System.Configuration;
using System.Reflection;
using System.Text;

namespace HiSun.DALFactory
{
    /// <summary>
    /// This class is implemented following the Abstract Factory pattern to create the DAL implementation
    /// specified from the configuration file
    /// </summary>
    public sealed class DataAccess
    {

        // Look up the DAL implementation we should be using
        private static readonly string path = ConfigurationManager.AppSettings["WebDAL"];
        //private static readonly string orderPath = ConfigurationManager.AppSettings["OrdersDAL"];

        private DataAccess() { }

        public static HiSun.IDAL.IGroup CreateGroup()
        {
            string className = path + ".GroupDAL";
            return (HiSun.IDAL.IGroup)Assembly.Load(path).CreateInstance(className);
        }

        //public static PetShop.IDAL.IInventory CreateInventory()
        //{
        //    string className = path + ".Inventory";
        //    return (PetShop.IDAL.IInventory)Assembly.Load(path).CreateInstance(className);
        //}

        //public static PetShop.IDAL.IItem CreateItem()
        //{
        //    string className = path + ".Item";
        //    return (PetShop.IDAL.IItem)Assembly.Load(path).CreateInstance(className);
        //}

        //public static PetShop.IDAL.IOrder CreateOrder()
        //{
        //    string className = orderPath + ".Order";
        //    return (PetShop.IDAL.IOrder)Assembly.Load(orderPath).CreateInstance(className);
        //}

        //public static PetShop.IDAL.IProduct CreateProduct()
        //{
        //    string className = path + ".Product";
        //    return (PetShop.IDAL.IProduct)Assembly.Load(path).CreateInstance(className);
        //}

    }
}
